let iosDownload = 'https://itunes.apple.com/cn/app/%E5%88%86%E5%8A%A8%E5%9C%88/id1397390199?l=zh&ls=1&mt=8'
let androidDownload = 'http://sj.qq.com/myapp/detail.htm?apkName=com.kct.fundoHealth.btnotification'
let isIos = /(phone|pad|pod|iPhone|iPod|ios)/i.test(navigator.userAgent)
let isAndroid = /Android/i.test(navigator.userAgent)
let pushCard = function () {
  if (isIos) {
    try {
      window.webkit.messageHandlers.sportStart.postMessage('')
    } catch (error) {}
  } else if (isAndroid) {
    try {
      // eslint-disable-next-line
      webview.sportStart()
    } catch (error) {}
  } else {
    console.log('运动打卡')
  }
}
let base64PicToAPP = function (data64) {
  console.log(data64)
  if (isIos) {
    try {
      window.webkit.messageHandlers.shareBusinessResultImage.postMessage(data64)
    } catch (error) {}
  } else if (isAndroid) {
    try {
      // eslint-disable-next-line
      webview.shareBusinessResultImage(data64)
    } catch (error) {}
  } else {
    console.log('base64ToApp')
  }
}

let activityId = 12
let addShare = function () {
  window.share = function () {
    return {
      shareTitleName: '迎新之战-1月跑量挑战锦标赛',
      shareTitlePic: 'http://group.fundo.xyz/fundogroup_activity_share/millage.png',
      shareContentUrl: 'http://group.fundo.xyz/fundogroup_activity/mileage/#/?',
      shareDescription: '2019赛季月度跑量系列挑战赛,参与赢新年大礼包！'
    }
  }
}
const onlineHost = 'http://group.funos.cn:8080'
const debugHost = 'http://121.201.66.218:8080'
const querySuffix = '/fundogroup/content/activity/protal/queryMyActivityInfo.do'
const signSuffix = '/fundogroup/content/activity/protal/signUpActivity.do'
const isSubmitInfoSuffix = '/fundogroup/content/activity/protal/queryAwardeeInfo.do'
const submitInfoSuffix = '/fundogroup/content/activity/protal/insertFundoAwardeeInfo.do'
let queryUrl = onlineHost + querySuffix
let signUpUrl = onlineHost + signSuffix
let submitInfoUrl = onlineHost + submitInfoSuffix
let isSubmitInfoUrl = onlineHost + isSubmitInfoSuffix

let runtimeEnvironment = 'prod'
const switchEnvironment = () => {
  switch (runtimeEnvironment) {
    case 'dev':
      queryUrl = '/api/api.json'
      signUpUrl = '/api/sign.json'
      submitInfoUrl = '/api/submit.json'
      isSubmitInfoUrl = '/api/isSubmit.json'
      break
    case 'test':
      queryUrl = debugHost + querySuffix
      signUpUrl = debugHost + signSuffix
      submitInfoUrl = debugHost + submitInfoSuffix
      isSubmitInfoUrl = debugHost + isSubmitInfoSuffix
      break
    case 'prod':
      break
  }
}
switchEnvironment()

export {
  iosDownload,
  androidDownload,
  isIos,
  isAndroid,
  activityId,
  pushCard,
  base64PicToAPP,
  addShare,
  queryUrl,
  signUpUrl,
  submitInfoUrl,
  isSubmitInfoUrl
}
